<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for utils/dateInfo.js</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="../prettify.css" />
    <link rel="stylesheet" href="../base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type='text/css'>
        .coverage-summary .sorter {
            background-image: url(../sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class='wrapper'>
  <div class='pad1'>
    <h1>
      <a href="../index.html">All files</a> / <a href="index.html">utils</a> dateInfo.js
    </h1>
    <div class='clearfix'>
      <div class='fl pad1y space-right2'>
        <span class="strong">40.52% </span>
        <span class="quiet">Statements</span>
        <span class='fraction'>62/153</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">28.65% </span>
        <span class="quiet">Branches</span>
        <span class='fraction'>49/171</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">24.44% </span>
        <span class="quiet">Functions</span>
        <span class='fraction'>11/45</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">39.82% </span>
        <span class="quiet">Lines</span>
        <span class='fraction'>45/113</span>
      </div>
    </div>
  </div>
  <div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">11x</span>
<span class="cline-any cline-yes">11x</span>
<span class="cline-any cline-yes">11x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">5x</span>
<span class="cline-any cline-yes">5x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">8x</span>
<span class="cline-any cline-yes">8x</span>
<span class="cline-any cline-yes">8x</span>
<span class="cline-any cline-yes">8x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">8x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">8x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">13x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">13x</span>
<span class="cline-any cline-yes">8x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">5x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">8x</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import {
  isDate,
  isString,
  isNumber,
  isObject,
  isArray,
  isFunction,
} from './typeCheckers';
import defaults from './defaults';
import { mixinOptionalProps } from './helpers';
&nbsp;
const millisecondsPerDay = 24 * 60 * 60 * 1000;
&nbsp;
export function addDays(date, days) {
  const result = new Date(date);
  result.setDate(result.getDate() + days);
  return result;
}
&nbsp;
// function compareDates(date1, date2) {
//   if (!date1 &amp;&amp; !date2) return 0;
//   if (!date1) return -1;
//   if (!date2) return 1;
//   return date1 - date2;
// }
&nbsp;
// function minDate(date1, date2) {
//   return compareDates(date1, date2) === -1 ? date1 : date2;
// }
&nbsp;
// Returns a date range that intersects two date info objects
// This is a shallow calculation (does not take patterns into account),
//   so this method should only really be called for special conditions
//   where absolute accuracy is not necessarily needed
// function findShallowIntersectingRange(date1, date2) {
//   const thisRange = date1.toRange();
//   const otherRange = date2.toRange();
//   // Start with infinite start and end dates
//   let start = null;
//   let end = null;
//   // This start date exists
//   if (thisRange.start) {
//     // Use this definite start date if other start date is infinite
//     if (!otherRange.start) start = thisRange.start;
//     // Otherwise, use the earliest start date
//     else start = thisRange.start &lt; otherRange.start ? thisRange.start : otherRange.start;
//   // Other start date exists
//   } else if (otherRange.start) {
//     // Use other definite start date as this one is infinite
//     start = otherRange.start;
//   }
//   // Assign end date to this one if it is valid
//   if (thisRange.end &amp;&amp; (!start || thisRange.end &gt; start)) {
//     end = thisRange.end;
//   }
//   // Assign end date to other one if it is valid and before this one
//   if (otherRange.end &amp;&amp; (!start || otherRange.end &gt; start)) {
//     end = minDate(end, otherRange.end);
//   }
//   // Return calculated range
//   return { start, end };
// }
// ========================================================
// Determines if first date completely includes second date
// This is a shallow test (no patterns tested)
function dateShallowIncludesDate(date1, date2) <span class="cstat-no" title="statement not covered" ><span class="cstat-no" title="statement not covered" >{</span></span>
  // First date is simple date
  <span class="missing-if-branch" title="else path not taken" >E</span>if (date1.isDate) {
    if (date2.isDate) return date1.dateTime === date2.dateTime;
    <span class="missing-if-branch" title="if path not taken" >I</span>if (<span class="cstat-no" title="statement not covered" >!</span>date2.startTime || !date2.endTime) return false;
    return date1.dateTime === date2.startTime &amp;&amp; date1.dateTime === date2.endTime;
  }
  // Second date is simple date and first is date range
  if (date2.isDate) {
<span class="cstat-no" title="statement not covered" >    if (<span class="cstat-no" title="statement not covered" >d</span>ate1.</span>start &amp;&amp; date2.date &lt; date1.start) return false;
<span class="cstat-no" title="statement not covered" >    if (<span class="cstat-no" title="statement not covered" >d</span>ate1.</span>end &amp;&amp; date2.date &gt; date1.end) return false;
<span class="cstat-no" title="statement not covered" >    return true;</span>
  }
  // Both dates are date ranges
  if (<span class="cstat-no" title="statement not covered" >date1.</span>start &amp;&amp; (!date2.start || date2.start &lt; date1.start)) return false;
<span class="cstat-no" title="statement not covered" >  if (<span class="cstat-no" title="statement not covered" >d</span>ate1.end &amp;&amp; (</span>!date2.end || date2.end &gt; date1.end)) return false;
<span class="cstat-no" title="statement not covered" >  return true;</span>
}
// ========================================================
// Determines if first date partially intersects second date
// This is a shallow test (no patterns tested)
function <span class="fstat-no" title="function not covered" >dateShallowIntersectsDate(date1, date2) <span class="cstat-no" title="statement not covered" >{</span></span>
<span class="cstat-no" title="statement not covered" >  if (date1.isDate) <span class="cstat-no" title="statement not covered" >return d</span></span>ate2.isDate ? date1.dateTime === date2.dateTime : dateShallowIncludesDate(date2, date1);
<span class="cstat-no" title="statement not covered" >  if (date2.isDate) <span class="cstat-no" title="statement not covered" >r</span>eturn </span>dateShallowIncludesDate(date1, date2);
  // Both ranges
  if (<span class="cstat-no" title="statement not covered" >date1.</span>start &amp;&amp; date2.end &amp;&amp; date1.start &gt; date2.end) return false;
<span class="cstat-no" title="statement not covered" >  if (<span class="cstat-no" title="statement not covered" >d</span>ate1.end &amp;&amp; </span>date2.start &amp;&amp; date1.end &lt; date2.start) return false;
<span class="cstat-no" title="statement not covered" >  return true;</span>
}
&nbsp;
function startOfWeek(date) {
  const day = date.getDay() + 1;
  const { firstDayOfWeek } = defaults;
  const <span class="branch-1 cbranch-no" title="branch not covered" >daysToAdd = d</span>ay &gt;= firstDayOfWeek ? firstDayOfWeek - day : -(7 - (firstDayOfWeek - day));
  return addDays(date, daysToAdd);
}
&nbsp;
function diffInDays(d1, d2) {
  return Math.round((d2 - d1) / millisecondsPerDay);
}
&nbsp;
function diffInWeeks(d1, d2) {
  return diffInDays(startOfWeek(d1), startOfWeek(d2));
}
&nbsp;
function diffInYears(d1, d2) {
  return d2.getUTCFullYear() - d1.getUTCFullYear();
}
&nbsp;
function diffInMonths(d1, d2) {
  return (diffInYears(d1, d2) * 12) + (d2.getMonth() - d1.getMonth());
}
&nbsp;
const _patterns = {
  dailyInterval: {
    test: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >(</span>dayInfo, interval, { start }) =&gt; d</span>iffInDays(start || new Date(), dayInfo.date) % interval === 0,
  },
  weeklyInterval: {
    test: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >(</span>dayInfo, interval, { start }) =&gt; d</span>iffInWeeks(start || new Date(), dayInfo.date) % interval === 0,
  },
  monthlyInterval: {
    test: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >(</span>dayInfo, interval, { start }) =&gt; d</span>iffInMonths(start || new Date(), dayInfo.date) % interval === 0,
  },
  yearlyInterval: {
    test: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >() =&gt; </span>(</span>dayInfo, interval, { start }) =&gt; diffInYears(start || new Date(), dayInfo.date) % interval === 0,
  },
  days: {
    validate: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >days =&gt; (</span>i</span>sArray(days) ? days : [parseInt(days, 10)]),
    test: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >(</span>dayInfo, days) =&gt; d</span>ays.includes(dayInfo.day) || days.includes(-dayInfo.dayFromEnd),
  },
  weekdays: {
    validate: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >weekdays =&gt; (</span>i</span>sArray(weekdays) ? weekdays : [parseInt(weekdays, 10)]),
    test: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >(</span>dayInfo, weekdays) =&gt; weekdays.includes(dayInfo.weekday),</span>
  },
  ordinalWeekdays: {
    validate: <span class="fstat-no" title="function not covered" >ordinalWeekdays =&gt;</span>
<span class="cstat-no" title="statement not covered" >      Object.keys(ordinalWeekdays)</span>
        .reduce(<span class="fstat-no" title="function not covered" >(</span>obj, ck) =&gt; {
          const <span class="cstat-no" title="statement not covered" >weekdays = </span>ordinalWeekdays[ck];
<span class="cstat-no" title="statement not covered" >          if (!weekdays) <span class="cstat-no" title="statement not covered" >r</span>eturn </span>obj;
<span class="cstat-no" title="statement not covered" >          obj[ck] = isArray(w</span>eekdays) ? weekdays : [parseInt(weekdays, 10)];
<span class="cstat-no" title="statement not covered" >          return obj;</span>
        }, {}),
    test: <span class="fstat-no" title="function not covered" >(</span>dayInfo, ordinalWeekdays) =&gt;
<span class="cstat-no" title="statement not covered" >      Object.keys(ordinalWeekdays)</span>
        .map(<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >k =&gt; </span>p</span>arseInt(k, 10))
        .find(<span class="fstat-no" title="function not covered" >k =&gt;</span>
<span class="cstat-no" title="statement not covered" >          ordinalWeekdays[k].includes(dayInfo.weekday) &amp;&amp;</span>
          (k === dayInfo.weekdayOrdinal || k === -dayInfo.weekdayOrdinalFromEnd)),
  },
  weekends: {
    validate: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >config =&gt; </span></span>config,
    test: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >dayInfo =&gt; </span>d</span>ayInfo.weekday === 1 || dayInfo.weekday === 7,
  },
  workweek: {
    validate: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >config =&gt; </span></span>config,
    test: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >dayInfo =&gt; </span>d</span>ayInfo.weekday &gt;= 2 &amp;&amp; dayInfo.weekday &lt;= 6,
  },
  weeks: {
    validate: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >weeks =&gt; (</span>i</span>sArray(weeks) ? weeks : [parseInt(weeks, 10)]),
    test: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >(</span>dayInfo, weeks) =&gt; w</span>eeks.includes(dayInfo.week) || weeks.includes(-dayInfo.weekFromEnd),
  },
  months: {
    validate: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >months =&gt; (</span>i</span>sArray(months) ? months : [parseInt(months, 10)]),
    test: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >(</span>dayInfo, m</span>onths) =&gt; months.includes(dayInfo.month),
  },
  years: {
    validate: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >years =&gt; (</span>i</span>sArray(years) ? years : [parseInt(years, 10)]),
    test: <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >(</span>dayInfo, </span>years) =&gt; years.includes(dayInfo.year),
  },
};
const _patternProps = Object.keys(_patterns).map(k =&gt; ({ name: k, validate: _patterns[k].validate }));
const testConfig = <span class="fstat-no" title="function not covered" >(config, dayInfo, info) =&gt; {</span>
<span class="cstat-no" title="statement not covered" >  if (<span class="cstat-no" title="statement not covered" >i</span>sFunction(</span>config)) return config(dayInfo);
<span class="cstat-no" title="statement not covered" >  if (isObject(config)) {</span>
<span class="cstat-no" title="statement not covered" >    return <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >Object.keys(</span>config).every(k =&gt; _</span></span>patterns[k].test(dayInfo, config[k], info));
  }
<span class="cstat-no" title="statement not covered" >  return null;</span>
};
&nbsp;
const DateInfo = (config, order) =&gt; <span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" ><span class="fstat-no" title="function not covered" >{</span></span></span></span>
  <span class="missing-if-branch" title="if path not taken" >I</span>if (!config) <span class="cstat-no" title="statement not covered" >return </span>null;
  const info = {
    isDateInfo: true,
    isDate: isDate(config) || isString(config) || isNumber(config),
    isRange: isObject(config) || isFunction(config),
    order: order || 0,
  };
  // Process date
  if (info.isDate) <span class="missing-if-branch" title="if path not taken" >I</span>{
    info.type = 'date';
    // Initialize date from config
    const date = new Date(config);
    // Can't accept invalid dates
    if (isNaN(date)) return null;
    // Strip date time
    date.setHours(0, 0, 0, 0);
    // Assign date
    info.date = date;
    info.dateTime = date.getTime();
  }
  // Process date range
  if (info.isRange) <span class="missing-if-branch" title="if path not taken" >I</span>{
    info.type = 'range';
    // Date config is a function
    if (isFunction(config)) {
<span class="cstat-no" title="statement not covered" >      info.on = { and: config };</span>
    // Date config is an object
    } else <span class="missing-if-branch" title="if path not taken" >I</span><span class="missing-if-branch" title="else path not taken" >E</span><span class="missing-if-branch" title="else path not taken" >E</span><span class="missing-if-branch" title="if path not taken" >I</span>{
      // Initialize start and end dates (null means infinity)
      let start = config.start &amp;&amp; new Date(config.start);
      let end = config.end &amp;&amp; new Date(config.end);
      // Reconfigure start and end dates if needed
      if (start &amp;&amp; end &amp;&amp; start &gt; end) {
        const <span class="cstat-no" title="statement not covered" >temp = </span>start;
<span class="cstat-no" title="statement not covered" >        start = end;</span>
<span class="cstat-no" title="statement not covered" >        end = temp;</span>
      } else <span class="missing-if-branch" title="if path not taken" >I</span>if (start &amp;&amp; config.span &gt;= 1) {
<span class="cstat-no" title="statement not covered" >        end = addDays(start, c</span>onfig.span - 1);
      }
      // Reset invalid dates to null and strip times for valid dates
      if (start) {
        <span class="missing-if-branch" title="if path not taken" >I</span>if (isNaN(start.getTime())) <span class="cstat-no" title="statement not covered" >start = </span>null;
        else start.setHours(0, 0, 0, 0);
      }
      <span class="missing-if-branch" title="else path not taken" >E</span>if (end) {
        <span class="missing-if-branch" title="if path not taken" >I</span>if (isNaN(end.getTime())) <span class="cstat-no" title="statement not covered" >end = </span>null;
        else end.setHours(0, 0, 0, 0);
      }
      // Assign start and end dates
      info.start = start;
      info.end = end;
      info.startTime = start &amp;&amp; start.getTime();
      info.endTime = end &amp;&amp; end.getTime();
      // Assign span info
      if (start &amp;&amp; end) {
        info.daySpan = diffInDays(start, end);
        info.weekSpan = diffInWeeks(start, end);
        info.monthSpan = diffInMonths(start, end);
        info.yearSpan = diffInYears(start, end);
      }
      // Assign 'and' condition
      const andOpt = mixinOptionalProps(config, {}, _patternProps);
      <span class="missing-if-branch" title="if path not taken" >I</span>if (andOpt.assigned) {
<span class="cstat-no" title="statement not covered" >        info.on = { and: andOpt.target };</span>
      }
      // Assign 'or' conditions
      if (config.on) {
        const or =
          (<span class="cstat-no" title="statement not covered" >isArray(config.on) ? config.on : [config.on])</span>
          .map(<span class="fstat-no" title="function not covered" >(</span>o) =&gt; {
<span class="cstat-no" title="statement not covered" >            if (<span class="cstat-no" title="statement not covered" >i</span>sFunction(</span>o)) return o;
            const <span class="cstat-no" title="statement not covered" >opt = </span>mixinOptionalProps(o, {}, _patternProps);
<span class="cstat-no" title="statement not covered" >            return o</span>pt.assigned ? opt.target : null;
          })
          .filter(<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >o =&gt; </span></span>o);
<span class="cstat-no" title="statement not covered" >        if (or.length) <span class="cstat-no" title="statement not covered" >i</span>nfo.</span>on = { ...info.on, or };
      }
    }
    // Assign flag if date info is complex
    info.isComplex = !!info.on;
  }
  // ========================================================
  // Determines if this date completely includes another date
  // This is a shallow test (no patterns tested)
  info.shallowIncludes = other =&gt; dateShallowIncludesDate(info, other.isDate ? other : DateInfo(other));
  // ========================================================
  info.includes = other =&gt; info.shallowIncludes(other);
  // ========================================================
  // Determines if this date partially intersects another date
  // This is a shallow test (no patterns tested)
  info.shallowIntersects = other =&gt; dateShallowIntersectsDate(info, other.isDate ? other : DateInfo(other));
  // ========================================================
  info.intersects = (other) =&gt; <span class="cstat-no" title="statement not covered" >{</span>
    const <span class="cstat-no" title="statement not covered" >i = </span>info.shallowIntersects(other);
    // const intersectingRange = findShallowIntersectingRange(info, other.isDateInfo ? other : DateInfo(other));
    return i;
  };
  // ========================================================
  // Finds the first match for the given day
  info.includesDay = (dayInfo) =&gt; <span class="cstat-no" title="statement not covered" ><span class="cstat-no" title="statement not covered" ><span class="cstat-no" title="statement not covered" ><span class="cstat-no" title="statement not covered" >{</span></span></span></span>
    const <span class="cstat-no" title="statement not covered" >date = </span>DateInfo(dayInfo.date);
    // Date is outside general range - return null
    if (!info.shallowIncludes(date)) return null;
<span class="cstat-no" title="statement not covered" >    if (!info.on) <span class="cstat-no" title="statement not covered" >r</span>eturn </span>info;
    // Fail if 'and' condition fails
    if (<span class="cstat-no" title="statement not covered" >info.</span>on.and &amp;&amp; !testConfig(info.on.and, dayInfo, info)) return null;
    // Fail if every 'or' condition fails
    if (<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >info.</span></span>on.or &amp;&amp; !info.on.or.find(or =&gt; testConfig(or, dayInfo, info))) return null;
    // Return date info for day date
    return date;
  };
  info.toRange = <span class="fstat-no" title="function not covered" >() =&gt; </span>{
<span class="cstat-no" title="statement not covered" >    if (info.isDate) {</span>
      return DateInfo({
        start: info.date,
        end: info.date,
      });
    }
    return DateInfo({
      start: info.start,
      end: info.end,
    });
  };
  // Build the 'compare to other' function
  info.compare = (other) =&gt; {
<span class="cstat-no" title="statement not covered" >    if (info.order !== other.order) <span class="cstat-no" title="statement not covered" >r</span>eturn </span>info.order - other.order;
<span class="cstat-no" title="statement not covered" >    if (info.type !== other.type) <span class="cstat-no" title="statement not covered" >r</span>eturn </span>info.isDate ? 1 : -1;
<span class="cstat-no" title="statement not covered" >    if (info.isDate) <span class="cstat-no" title="statement not covered" >r</span>eturn </span>0;
    const <span class="cstat-no" title="statement not covered" >diff = </span>info.start - other.start;
<span class="cstat-no" title="statement not covered" >    return d</span>iff !== 0 ? diff : info.end - other.end;
  };
  // Return fully configured date info object
  return info;
};
&nbsp;
export default DateInfo;
&nbsp;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
  Code coverage
  generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Fri Jan 05 2018 11:32:47 GMT-0600 (CST)
</div>
</div>
<script src="../prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="../sorter.js"></script>
</body>
</html>
